package com.zmz.lambda;

import java.util.ArrayList;
import java.util.List;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2022/07/30/19:47
 * @Description:  用lambda表达式遍历复杂集合
 */
public class Lambda06 {
    public static  void main(String [] args){
        List<Item2>  list = new ArrayList<>();
        list.add(new Item2(1,"阿萨",12.22));
        list.add(new Item2(2,"撒旦",12.21));
        list.add(new Item2(3,"答案",11.22));

        //以前的遍历方法
        for(int i =0 ;i<list.size() ;i++){
            System.out.println(list.get(i).id);
        }

        for(Item2 item2 :list){
            System.out.println(item2.getName());
        }

        list.forEach(i->System.out.println(i.getPrice()));

        list.forEach(System.out::println);
    }
}
